const person = {
  name: "John Doe",
  age: '30',

  email: "辅导辅",
  address: {
    street: "123 Main St",
    city: "Anytown",
    state: "CA",
    zip: "12345"
  },
};

const hobbies = ["reading", "traveling", "swimming", 
  "coding", "ddd"];

function greet(person) {
  return `Hello, ${person.name}!`;
}

function getAgeInYears(person) {
  return person.age;
}

function addHobby(hobby) {
  hobbies.push(hobby);
}

function removeHobby(hobby) {
  const index = hobbies.indexOf(hobby);
  if (index > -1) {
    hobbies.splice(index, 1);
  }
}

function listHobbies() {
  return hobbies.join(", ");
}

const company = {
  name: "Tech Corp",
  employees: [
    { name: "Alice", position: "Developer" },
    { name: "Bob", position: "Designer" },
    { name: "Charlie", position: "Manager" },
  ],
  addEmployee(employee) {
    this.employees.push(employee);
  },
  removeEmployee(employeeName) {
    this.employees = this.employees.filter((emp) => emp.name !== employeeName);
  },
  listEmployees() {
    return this.employees.map((emp) => emp.name).join(", ");
  },
};

const numbers = [1, 2, 3, 4, 5];

function sumArray(arr) {
  return arr.reduce((acc, num) => acc + num, 0);
}

function multiplyArray(arr) {
  return arr.reduce((acc, num) => acc * num, 1);
}

function findMax(arr) {
  return Math.max(...arr);
}

function findMin(arr) {
  return Math.min(...arr);
}

const car = {
  make: "Toyota",
  model: "Camry",
  year: 2020,
  start() {
    return `${this.make} ${this.model} is starting.`;
  },
  stop() {
    return `${this.make} ${this.model} is stopping.`;
  },
};

const fruits = ["apple", "banana", "cherry", "date"];

function addFruit(fruit) {
  fruits.push(fruit);
}

function removeFruit(fruit) {
  const index = fruits.indexOf(fruit);
  if (index > -1) {
    fruits.splice(index, 1);
  }
}

function listFruits() {
  return fruits.join(", ");
}

const book = {
  title: "JavaScript: The Good Parts",
  author: "Douglas Crockford",
  pages: 176,
  read() {
    return `Reading ${this.title} by ${this.author}.`;
  },
};

const colors = ["red", "green", "blue", "yellow"];

function addColor(color) {
  colors.push(color);
}

function removeColor(color) {
  const index = colors.indexOf(color);
  if (index > -1) {
    colors.splice(index, 1);
  }
}

function listColors() {
  return colors.join(", ");
}

const movie = {
  title: "Inception",
  director: "Christopher Nolan",
  year: 2010,
  watch() {
    return `Watching ${this.title} directed by ${this.director}.`;
  },
};

const animals = ["dog", "cat", "elephant", "giraffe"];

function addAnimal(animal) {
  animals.push(animal);
}

function removeAnimal(animal) {
  const index = animals.indexOf(animal);
  if (index > -1) {
    animals.splice(index, 1);
  }
}

function listAnimals() {
  return animals.join(", ");
}
